define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'seller_log/index' + location.search,
                    del_url: 'seller_log/del',
                    table: 'seller_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                       /* {field: 'user_id', title: __('User_id')},
                        {field: 'activity_id', title: __('Activity_id')},*/
                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                        {field: 'user.avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
                        {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
                        {field: 'activity.title', title: __('Activity.title'), operate: 'LIKE'},
                        //{field: 'video.video', title: __('预览'), formatter: Controller.api.formatter.thumb, operate: false},
                        {field: 'user.open_id', title: __('open_id'), operate: false},

                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('更新时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                     /*   {field: 'video_id', title: __('Video_id')},*/
                     /*   {field: 'video_code', title: __('Video_code'), operate: 'LIKE'},*/
                        {field: 'avg_play_duration', title: __('Avg_play_duration'), operate: 'LIKE'},
                        {field: 'total_comment', title: __('Total_comment')},
                        {field: 'total_like', title: __('Total_like')},
                        {field: 'total_play', title: __('Total_play')},
                        {field: 'total_share', title: __('Total_share')},

                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons:[
                                {
                                    name:"update",
                                    text:"更新",
                                    icon:"fa fa-circle-o-notch",
                                    url:"seller_log/update",
                                    refresh:true,
                                    classname:"btn btn-xs btn-success btn-ajax",


                                }], formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
   /*     add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },*/
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            formatter: {
                thumb: function (value, row, index) {

                    return '<a href="' + value + '" target="_blank"><span style="max-height:90px;max-width:120px">mp4</span></a>';


                }
            }
        }
    };
    return Controller;
});